
#Author: Kevin Aslett
#Code Title: Main_Text.R
#Paper Title: Testing The Effect of Information on Discerning the Veracity of News in Real-Time
#Purpose of code: Generate all figures that are located in the main tex.

#FILES IN:
#Study 1 Data (False/Misleading Articles): Exp_3_Data.csv
#Study 1 Data (True Articles): Exp_3_Data_True.csv
#Study 2 Data (False/Misleading Articles): MF_Search_Exp_Misl_False.csv
#Study 2 Data (True Articles): T_Search_Exp_Misl_False.csv

#FILES OUT:
#Figure 3: Coefficients_1.png
#Figure 4: Coefficients_2.png
#Figure 5a: Coefficients_3.png
#Figure 5b: Coefficients_4.png
#Figure 6: Coefficients_5.png
#Session Information: sessionInfo_Main_Text.txt

#Load in libraries
library(ggplot2)
library(dplyr)
library(reshape2)
library(tidyverse)
library(Rmisc)
library(plm)
library(lmtest)
library(sandwich)
library(rsq)

############################# Load Data ###################################################


########### Study 2 - False/Misleading Articles:

Misl_False_Search_MF <- read_csv('.//data//MF_Search_Exp_Misl_False.csv',
                                 col_types = cols(
                                   .default = col_character()
                                 ))

Misl_False_Search_MF$Match_FC <- ifelse(Misl_False_Search_MF$Evaluation == 'FM',1,0)
Misl_False_Search_MF$Match_FC <- ifelse(Misl_False_Search_MF$Evaluation == 'Misl/False',1,Misl_False_Search_MF$Match_FC)

Misl_False_Search_MF$Susc_FN <- ifelse(Misl_False_Search_MF$Evaluation == 'T',1,0)
Misl_False_Search_MF$Susc_FN <- ifelse(Misl_False_Search_MF$Evaluation == 'True',1,Misl_False_Search_MF$Susc_FN)

########### Study 2 - True Articles:

Misl_False_Search_T <- read_csv('.//data//T_Search_Exp_Misl_False.csv',
                                col_types = cols(
                                  .default = col_character()
                                ))



Misl_False_Search_T$Match_FC <- ifelse(Misl_False_Search_T$Evaluation == 'T',1,0)
Misl_False_Search_T$Match_FC <- ifelse(Misl_False_Search_T$Evaluation == 'True',1,Misl_False_Search_T$Match_FC)

Misl_False_Search_T$Susc_FN <- ifelse(Misl_False_Search_T$Evaluation == 'FM',1,0)
Misl_False_Search_T$Susc_FN <- ifelse(Misl_False_Search_T$Evaluation == 'Misl/False',1,Misl_False_Search_T$Susc_FN)



########### Study 1 - False/Misleading Articles:

Experiment_3_Data <- read_csv('.//data//Exp_3_Data.csv',
                              col_types = cols(
                                .default = col_character()
                              ))


Experiment_3_Data$Match_FC <- ifelse(Experiment_3_Data$Evaluation == 'FM',1,0)
Experiment_3_Data$Susc_FN <- ifelse(Experiment_3_Data$Evaluation == 'T',1,0)

########### Study 1 - True Articles:

Experiment_3_Data_T <- read_csv('.//data//Exp_3_Data_True.csv',
                                col_types = cols(
                                  .default = col_character()
                                ))

Experiment_3_Data_T$Match_FC <- ifelse(Experiment_3_Data_T$Evaluation == 'T',1,0)
Experiment_3_Data_T$Susc_FN <- ifelse(Experiment_3_Data_T$Evaluation == 'FM',1,0)

#Create Congruence Data (False/misleading Articles):

Experiment_3_Data$Dummy_Incongruence <- ifelse(Experiment_3_Data$lean == 'L' & Experiment_3_Data$Ideology_Score > 0,1,0)
Experiment_3_Data$Dummy_Incongruence <- ifelse(Experiment_3_Data$lean == 'C' & Experiment_3_Data$Ideology_Score < 0,1,Experiment_3_Data$Dummy_Incongruence)
Experiment_3_Data$Dummy_Incongruence <- ifelse(is.na(Experiment_3_Data$Ideology_Score),NA,Experiment_3_Data$Dummy_Incongruence)

Experiment_3_Data$Congruent_Word <- ifelse(Experiment_3_Data$Dummy_Incongruence == 1,'Incongruent','Moderate')
Experiment_3_Data$Congruent_Word <- ifelse(Experiment_3_Data$Dummy_Congruence == 1,'Congruent',Experiment_3_Data$Congruent_Word)
Experiment_3_Data$Congruent_Word <- ifelse(is.na(Experiment_3_Data$Ideology_Score),NA,Experiment_3_Data$Congruent_Word)


#Create Congruence Data (True Articles):

Experiment_3_Data_T$Dummy_Incongruence <- ifelse(Experiment_3_Data_T$lean == 'L' & Experiment_3_Data_T$Ideology_Score > 0,1,0)
Experiment_3_Data_T$Dummy_Incongruence <- ifelse(Experiment_3_Data_T$lean == 'C' & Experiment_3_Data_T$Ideology_Score < 0,1,Experiment_3_Data_T$Dummy_Incongruence)
Experiment_3_Data_T$Dummy_Incongruence <- ifelse(is.na(Experiment_3_Data_T$Ideology_Score),NA,Experiment_3_Data_T$Dummy_Incongruence)

Experiment_3_Data_T$Congruent_Word <- ifelse(Experiment_3_Data_T$Dummy_Incongruence == 1,'Incongruent','Moderate')
Experiment_3_Data_T$Congruent_Word <- ifelse(Experiment_3_Data_T$Dummy_Congruence == 1,'Congruent',Experiment_3_Data_T$Congruent_Word)
Experiment_3_Data_T$Congruent_Word <- ifelse(is.na(Experiment_3_Data_T$Ideology_Score),NA,Experiment_3_Data_T$Congruent_Word)




############### Linear regression Results testing Hypothesis 3.1

#Select variables needed:
Misl_False_Search_1 <- Misl_False_Search_MF %>% select(Match_FC,Treat_Search,Education_Score,Age,Gender,Income_Score,Familiar_Dummy,Article_day,ResponseId,Ideology_Score)

#Remove NA values:
Misl_False_Search_1 = na.omit(Misl_False_Search_1)

#Clean Data:
Misl_False_Search_1$Match_FC <- as.numeric(Misl_False_Search_1$Match_FC)
Misl_False_Search_1$Age <- as.numeric(Misl_False_Search_1$Age)
Misl_False_Search_1$Treat_Search <- as.numeric(Misl_False_Search_1$Treat_Search)
Misl_False_Search_1$Education_Score <- as.numeric(Misl_False_Search_1$Education_Score)
Misl_False_Search_1$Income_Score <- as.numeric(Misl_False_Search_1$Income_Score)
Misl_False_Search_1$Ideology_Score <- as.numeric(Misl_False_Search_1$Ideology_Score)

#Run linear regression and produce coefficient values:
fit_Search_MF_T_1 = glm(Match_FC ~ Treat_Search + Education_Score + Age + Gender + Income_Score + Ideology_Score, data = Misl_False_Search_1)
#Produce clustere standard errors:
CI_Search_MF_T_1 = coefci(fit_Search_MF_T_1, vcov. = vcovCL(fit_Search_MF_T_1, cluster = list(Misl_False_Search_1$ResponseId), type = "HC0"))

lin_Search_Separate_MF_T_1 = coeftest(fit_Search_MF_T_1, vcov. = vcovCL(fit_Search_MF_T_1, cluster = list(Misl_False_Search_1$ResponseId), type = "HC0"))


# Return Number of observations:
Obs_Tab_1_1 <- nrow(Misl_False_Search_1)
# Return R-squared
Rsq_Tab_1_1 <- rsq(fit_Search_MF_T_1)
A_Rsq_Tab_1_1 <- rsq(fit_Search_MF_T_1,adj=TRUE)
A_Rsq_Tab_1_1 <- round(A_Rsq_Tab_1_1,3)
Rsq_Tab_1_1 <- round(Rsq_Tab_1_1,3)

# Return F-statistic
glm.0 <- glm(Match_FC ~ 1,data=Misl_False_Search_1)
Results <- anova(fit_Search_MF_T_1, glm.0, test="F")
F_Tab_1_1 <- Results$F[2]
F_Tab_1_1 <- round(F_Tab_1_1,3)
F_Tab_1_1 <- paste0(F_Tab_1_1,'^{***}')

#Create list of unique articles evaluated:
Search_Articles_1 <- unique(Misl_False_Search_1$Article_day)




############### Linear regression Results testing Hypothesis 3.2

#Select variables needed:
Misl_False_Search_1 <- Misl_False_Search_MF %>% select(Susc_FN,Treat_Search,Education_Score,Age,Gender,Income_Score,Familiar_Dummy,Article_day,ResponseId,Ideology_Score)

#Remove NA values:
Misl_False_Search_1 = na.omit(Misl_False_Search_1)

#Clean Data:
Misl_False_Search_1$Susc_FN <- as.numeric(Misl_False_Search_1$Susc_FN)
Misl_False_Search_1$Age <- as.numeric(Misl_False_Search_1$Age)
Misl_False_Search_1$Treat_Search <- as.numeric(Misl_False_Search_1$Treat_Search)
Misl_False_Search_1$Education_Score <- as.numeric(Misl_False_Search_1$Education_Score)
Misl_False_Search_1$Income_Score <- as.numeric(Misl_False_Search_1$Income_Score)
Misl_False_Search_1$Ideology_Score <- as.numeric(Misl_False_Search_1$Ideology_Score)


Misl_False_Search_Fig_1 <- Misl_False_Search_1 %>% mutate(Treat_Search_Cat = ifelse(Treat_Search == 0,'Control', 'Treatment'))

#Run linear regression and produce coefficient values:
fit_Search_MF_T_2 = glm(Susc_FN ~ Treat_Search + Education_Score + Age + Gender + Income_Score + Ideology_Score, data = Misl_False_Search_1)
#Produce clustere standard errors:
CI_Search_MF_T_2 = coefci(fit_Search_MF_T_2, vcov. = vcovCL(fit_Search_MF_T_2, cluster = list(Misl_False_Search_1$ResponseId), type = "HC0"))

lin_Search_Separate_MF_T_2 = coeftest(fit_Search_MF_T_2, vcov. = vcovCL(fit_Search_MF_T_2, cluster = list(Misl_False_Search_1$ResponseId), type = "HC0"))


# Return Number of observations:
Obs_Tab_1_2 <- nrow(Misl_False_Search_1)

# Return R-squared
Rsq_Tab_1_2 <- rsq(fit_Search_MF_T_2)
A_Rsq_Tab_1_2 <- rsq(fit_Search_MF_T_2,adj=TRUE)
A_Rsq_Tab_1_2 <- round(A_Rsq_Tab_1_2,3)
Rsq_Tab_1_2 <- round(Rsq_Tab_1_2,3)


# Return F-statistic
glm.0 <- glm(Susc_FN ~ 1,data=Misl_False_Search_1)
Results <- anova(fit_Search_MF_T_2, glm.0, test="F")
F_Tab_1_2 <- Results$F[2]
F_Tab_1_2 <- round(F_Tab_1_2,3)
F_Tab_1_2 <- paste0(F_Tab_1_2,'^{***}')

#Create list of unique articles evaluated:
Search_Articles_2 <- unique(Misl_False_Search_1$Article_day)



############### Linear regression Results testing Hypothesis 3.3

#Select variables needed:
Misl_False_Search_1 <- Misl_False_Search_T %>% select(Match_FC,Treat_Search,Education_Score,Age,Gender,Income_Score,Familiar_Dummy,Article_day,ResponseId,Ideology_Score)

#Remove NA values:
Misl_False_Search_1 = na.omit(Misl_False_Search_1)

#Clean Data:
Misl_False_Search_1$Match_FC <- as.numeric(Misl_False_Search_1$Match_FC)
Misl_False_Search_1$Age <- as.numeric(Misl_False_Search_1$Age)
Misl_False_Search_1$Treat_Search <- as.numeric(Misl_False_Search_1$Treat_Search)
Misl_False_Search_1$Education_Score <- as.numeric(Misl_False_Search_1$Education_Score)
Misl_False_Search_1$Income_Score <- as.numeric(Misl_False_Search_1$Income_Score)
Misl_False_Search_1$Ideology_Score <- as.numeric(Misl_False_Search_1$Ideology_Score)

#Run linear regression and produce coefficient values:
fit_Search_MF_T_3 = glm(Match_FC ~ Treat_Search + Education_Score + Age + Gender + Income_Score + Ideology_Score, data = Misl_False_Search_1)
#Produce clustere standard errors:
CI_Search_MF_T_3 = coefci(fit_Search_MF_T_3, vcov. = vcovCL(fit_Search_MF_T_3, cluster = list(Misl_False_Search_1$ResponseId), type = "HC0"))

lin_Search_Separate_MF_T_3 = coeftest(fit_Search_MF_T_3, vcov. = vcovCL(fit_Search_MF_T_3, cluster = list(Misl_False_Search_1$ResponseId), type = "HC0"))


# Return Number of observations:
Obs_Tab_1_3 <- nrow(Misl_False_Search_1)

# Return R-squared
Rsq_Tab_1_3 <- rsq(fit_Search_MF_T_3)
A_Rsq_Tab_1_3 <- rsq(fit_Search_MF_T_3,adj=TRUE)
A_Rsq_Tab_1_3 <- round(A_Rsq_Tab_1_3,3)
Rsq_Tab_1_3 <- round(Rsq_Tab_1_3,3)


# Return F-statistic
glm.0 <- glm(Match_FC ~ 1,data=Misl_False_Search_1)
Results <- anova(fit_Search_MF_T_3, glm.0, test="F")
F_Tab_1_3 <- Results$F[2]
F_Tab_1_3 <- round(F_Tab_1_3,3)
F_Tab_1_3 <- paste0(F_Tab_1_3,'^{***}')

#List of unique articles:
Search_Articles_3 <- unique(Misl_False_Search_1$Article_day)




############### Linear regression Results testing Hypothesis 2.1

#Create dataset needed:
Exp_3_Data <- rbind(Experiment_3_Data,Experiment_3_Data_T)
Exp_3_Data$Headline <- as.numeric(Exp_3_Data$Headline)
Exp_3_Data$Source <- as.numeric(Exp_3_Data$Source)
Exp_3_Data$Article <- as.numeric(Exp_3_Data$Article)
Full_Data <- Exp_3_Data %>% filter(Headline == 0)
Full_Data$Standardize <- ifelse(Full_Data$Source == 0,1,0)
Full_Data <- Full_Data %>% filter(Article == 1 | Article == 2 | Article == 3)
Full_Data$T_Dummy <- ifelse(Full_Data$Evaluation == 'T',1,0)
MF_Exp_3 <- Full_Data %>% select(T_Dummy,Standardize,Source,Education_Score,Age,Gender,Income_Score,Familiar_Dummy,Article_day,ResponseId,Ideology_Score)

#Remove NA values:
MF_Exp_3 <- na.omit(MF_Exp_3)

#Clean Data:
MF_Exp_3$T_Dummy <- as.numeric(MF_Exp_3$T_Dummy)
MF_Exp_3$Age <- as.numeric(MF_Exp_3$Age)
MF_Exp_3$Standardize <- as.numeric(MF_Exp_3$Standardize)
MF_Exp_3$Education_Score <- as.numeric(MF_Exp_3$Education_Score)
MF_Exp_3$Income_Score <- as.numeric(MF_Exp_3$Income_Score)
MF_Exp_3$Ideology_Score <- as.numeric(MF_Exp_3$Ideology_Score)

#Run linear regression and produce coefficient values:
fit_Standardize_MF_T_1 = glm(T_Dummy ~ Source + Education_Score + Age + Gender + Income_Score + Ideology_Score, data = MF_Exp_3)
#Produce clustere standard errors:
CI_Standardize_MF_T_1 <- coefci(fit_Standardize_MF_T_1, vcov. = vcovCL(fit_Standardize_MF_T_1, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

lin_results_Standardize_MF_T_1 = coeftest(fit_Standardize_MF_T_1, vcov. = vcovCL(fit_Standardize_MF_T_1, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

# Return Number of observations:
Obs_Tab_3_1 <- nrow(MF_Exp_3)
# Return R-squared
Rsq_Tab_3_1 <- rsq(fit_Standardize_MF_T_1)
A_Rsq_Tab_3_1 <- rsq(fit_Standardize_MF_T_1,adj=TRUE)
A_Rsq_Tab_3_1 <- round(A_Rsq_Tab_3_1,3)
Rsq_Tab_3_1 <- round(Rsq_Tab_3_1,3)

# Return F-statistic
glm.0 <- glm(T_Dummy ~ 1,data=MF_Exp_3)
Results <- anova(fit_Standardize_MF_T_1, glm.0, test="F")
F_Tab_3_1 <- Results$F[2]
F_Tab_3_1 <- round(F_Tab_3_1,3)
F_Tab_3_1 <- paste0(F_Tab_3_1,'^{***}')

#List of unique articles:
Search_Articles_7 <- unique(MF_Exp_3$Article_day)




############### Linear regression Results testing Hypothesis 2.2

#Create dataset needed:
Exp_3_Data <- rbind(Experiment_3_Data,Experiment_3_Data_T)
Exp_3_Data$Headline <- as.numeric(Exp_3_Data$Headline)
Exp_3_Data$Source <- as.numeric(Exp_3_Data$Source)
Exp_3_Data$Article <- as.numeric(Exp_3_Data$Article)
Full_Data <- Exp_3_Data %>% filter(Headline == 0)
Full_Data$Standardize <- ifelse(Full_Data$Source == 0,1,0)
Full_Data <- Full_Data %>% filter(Article == 4 | Article == 5)
Full_Data$T_Dummy <- ifelse(Full_Data$Evaluation == 'T',1,0)

MF_Exp_3 <- Full_Data %>% select(T_Dummy,Standardize,Source,Education_Score,Age,Gender,Income_Score,Familiar_Dummy,Article_day,ResponseId,Ideology_Score)

#Remove NA values:
MF_Exp_3 <- na.omit(MF_Exp_3)

#Clean data:
MF_Exp_3$T_Dummy <- as.numeric(MF_Exp_3$T_Dummy)
MF_Exp_3$Age <- as.numeric(MF_Exp_3$Age)
MF_Exp_3$Standardize <- as.numeric(MF_Exp_3$Standardize)
MF_Exp_3$Education_Score <- as.numeric(MF_Exp_3$Education_Score)
MF_Exp_3$Income_Score <- as.numeric(MF_Exp_3$Income_Score)
MF_Exp_3$Ideology_Score <- as.numeric(MF_Exp_3$Ideology_Score)


#Run linear regression and produce coefficient values:
fit_Standardize_MF_T_2 = glm(T_Dummy ~ Source + Education_Score + Age + Gender + Income_Score + Ideology_Score, data = MF_Exp_3)
#Produce clustere standard errors:
CI_Standardize_MF_T_2 <- coefci(fit_Standardize_MF_T_2, vcov. = vcovCL(fit_Standardize_MF_T_2, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

lin_results_Standardize_MF_T_2 = coeftest(fit_Standardize_MF_T_2, vcov. = vcovCL(fit_Standardize_MF_T_2, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))


# Return Number of observations:
Obs_Tab_3_2 <- nrow(MF_Exp_3)

# Return R-squared
Rsq_Tab_3_2 <- rsq(fit_Standardize_MF_T_2)
A_Rsq_Tab_3_2 <- rsq(fit_Standardize_MF_T_2,adj=TRUE)
A_Rsq_Tab_3_2 <- round(A_Rsq_Tab_3_2,3)
Rsq_Tab_3_2 <- round(Rsq_Tab_3_2,3)

# Return F-statistic
glm.0 <- glm(T_Dummy ~ 1,data=MF_Exp_3)
Results <- anova(fit_Standardize_MF_T_2, glm.0, test="F")
F_Tab_3_2 <- Results$F[2]
F_Tab_3_2 <- round(F_Tab_3_2,3)
F_Tab_3_2 <- paste0(F_Tab_3_2,'^{***}')

#List of unique articles
Search_Articles_8 <- unique(MF_Exp_3$Article_day)


############### Linear regression Results testing Hypothesis 2.3:

#Create dataset needed:
Exp_3_Data <- rbind(Experiment_3_Data,Experiment_3_Data_T)

#Clean data:
Exp_3_Data$Headline <- as.numeric(Exp_3_Data$Headline)
Exp_3_Data$Source <- as.numeric(Exp_3_Data$Source)
Exp_3_Data$Article <- as.numeric(Exp_3_Data$Article)
Exp_3_Data$Ideology_Score <- as.numeric(Exp_3_Data$Ideology_Score)
Full_Data <- Exp_3_Data %>% filter(Headline == 1)
Full_Data$Standardize <- ifelse(Full_Data$Source == 0,1,0)
Full_Data <- Full_Data %>% filter(Article == 1 | Article == 2 | Article == 3)
Full_Data$T_Dummy <- ifelse(Full_Data$Evaluation == 'T',1,0)

MF_Exp_3 <- Full_Data %>% select(T_Dummy,Standardize,Source,Education_Score,Age,Gender,Income_Score,Dummy_Congruence,Familiar_Dummy,Article_day,ResponseId,Ideology_Score)

#Remove NA values:
MF_Exp_3 <- na.omit(MF_Exp_3)

#Clean data:
MF_Exp_3$T_Dummy <- as.numeric(MF_Exp_3$T_Dummy)
MF_Exp_3$Age <- as.numeric(MF_Exp_3$Age)
MF_Exp_3$Standardize <- as.numeric(MF_Exp_3$Standardize)
MF_Exp_3$Education_Score <- as.numeric(MF_Exp_3$Education_Score)
MF_Exp_3$Income_Score <- as.numeric(MF_Exp_3$Income_Score)
MF_Exp_3$Ideology_Score <- as.numeric(MF_Exp_3$Ideology_Score)



#Run linear regression and produce coefficient values:
fit_Standardize_MF_T_5 = glm(T_Dummy ~ Source + Education_Score + Age + Gender + Income_Score + Ideology_Score, data = MF_Exp_3)
#Produce clustere standard errors:
CI_Standardize_MF_T_5 <- coefci(fit_Standardize_MF_T_5, vcov. = vcovCL(fit_Standardize_MF_T_5, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

lin_results_Standardize_MF_T_5 = coeftest(fit_Standardize_MF_T_5, vcov. = vcovCL(fit_Standardize_MF_T_5, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

# Return Number of observations:
Obs_Tab_3_5 <- nrow(MF_Exp_3)

# Return R-squared
Rsq_Tab_3_5 <- rsq(fit_Standardize_MF_T_5)
A_Rsq_Tab_3_5 <- rsq(fit_Standardize_MF_T_5,adj=TRUE)
A_Rsq_Tab_3_5 <- round(A_Rsq_Tab_3_5,3)
Rsq_Tab_3_5 <- round(Rsq_Tab_3_5,3)

# Return F-statistic
glm.0 <- glm(T_Dummy ~ 1,data=MF_Exp_3)
Results <- anova(fit_Standardize_MF_T_5, glm.0, test="F")
F_Tab_3_5 <- Results$F[2]
F_Tab_3_5 <- round(F_Tab_3_5,3)
F_Tab_3_5 <- paste0(F_Tab_3_5,'^{***}')

#List of unique articles:
Search_Articles_11 <- unique(MF_Exp_3$Article_day)




############### Linear regression Results testing Hypothesis 2.4:

#Create dataset needed:
Exp_3_Data <- rbind(Experiment_3_Data,Experiment_3_Data_T)
Exp_3_Data$Headline <- as.numeric(Exp_3_Data$Headline)
Exp_3_Data$Source <- as.numeric(Exp_3_Data$Source)
Exp_3_Data$Article <- as.numeric(Exp_3_Data$Article)
Exp_3_Data$Ideology_Score <- as.numeric(Exp_3_Data$Ideology_Score)
Full_Data <- Exp_3_Data %>% filter(Headline == 1)
Full_Data$Standardize <- ifelse(Full_Data$Source == 0,1,0)
Full_Data <- Full_Data %>% filter(Article == 4 | Article == 5)
Full_Data$T_Dummy <- ifelse(Full_Data$Evaluation == 'T',1,0)

#Select variables needed:
MF_Exp_3 <- Full_Data %>% select(T_Dummy,Standardize,Source,Education_Score,Age,Gender,Income_Score,Dummy_Congruence,Familiar_Dummy,Article_day,ResponseId,Ideology_Score)

#Remove NA values:
MF_Exp_3 <- na.omit(MF_Exp_3)

#Clean data:
MF_Exp_3$T_Dummy <- as.numeric(MF_Exp_3$T_Dummy)
MF_Exp_3$Age <- as.numeric(MF_Exp_3$Age)
MF_Exp_3$Standardize <- as.numeric(MF_Exp_3$Standardize)
MF_Exp_3$Education_Score <- as.numeric(MF_Exp_3$Education_Score)
MF_Exp_3$Income_Score <- as.numeric(MF_Exp_3$Income_Score)
MF_Exp_3$Ideology_Score <- as.numeric(MF_Exp_3$Ideology_Score)


#Run linear regression and produce coefficient values:
fit_Standardize_MF_T_6 = glm(T_Dummy ~ Source + Education_Score + Age + Gender + Income_Score + Ideology_Score, data = MF_Exp_3)
#Produce clustere standard errors:
CI_Standardize_MF_T_6 <- coefci(fit_Standardize_MF_T_6, vcov. = vcovCL(fit_Standardize_MF_T_6, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

lin_results_Standardize_MF_T_6 = coeftest(fit_Standardize_MF_T_6, vcov. = vcovCL(fit_Standardize_MF_T_6, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

# Return Number of observations:
Obs_Tab_3_6 <- nrow(MF_Exp_3)

# Return R-squared
Rsq_Tab_3_6 <- rsq(fit_Standardize_MF_T_6)
A_Rsq_Tab_3_6 <- rsq(fit_Standardize_MF_T_6,adj=TRUE)
A_Rsq_Tab_3_6 <- round(A_Rsq_Tab_3_6,3)
Rsq_Tab_3_6 <- round(Rsq_Tab_3_6,3)

# Return F-statistic
glm.0 <- glm(T_Dummy ~ 1,data=MF_Exp_3)
Results <- anova(fit_Standardize_MF_T_6, glm.0, test="F")
F_Tab_3_6 <- Results$F[2]
F_Tab_3_6 <- round(F_Tab_3_6,3)
F_Tab_3_6 <- paste0(F_Tab_3_6,'^{***}')

#List of unique articles:
Search_Articles_12 <- unique(MF_Exp_3$Article_day)




############### Linear regression Results testing Hypothesis 1.1

#Create dataset needed:
Exp_3_Data <- rbind(Experiment_3_Data,Experiment_3_Data_T)
Exp_3_Data$Headline <- as.numeric(Exp_3_Data$Headline)
Exp_3_Data$Source <- as.numeric(Exp_3_Data$Source)
Exp_3_Data$Article <- as.numeric(Exp_3_Data$Article)
Exp_3_Data$Dummy_Congruence <- as.numeric(Exp_3_Data$Dummy_Congruence)
Exp_3_Data$Ideology_Score <- as.numeric(Exp_3_Data$Ideology_Score)
Full_Data <- Exp_3_Data %>% filter(Source == 0)

#Select variables:
MF_Exp_3 <- Full_Data %>% select(Match_FC,Headline,Education_Score,Age,Gender,Income_Score,Dummy_Congruence,Familiar_Dummy,Article_day,ResponseId,Ideology_Score)

#Remove NA values:
MF_Exp_3 <- na.omit(MF_Exp_3)

#Clean data:
MF_Exp_3$Match_FC <- as.numeric(MF_Exp_3$Match_FC)
MF_Exp_3$Age <- as.numeric(MF_Exp_3$Age)
MF_Exp_3$Education_Score <- as.numeric(MF_Exp_3$Education_Score)
MF_Exp_3$Income_Score <- as.numeric(MF_Exp_3$Income_Score)
MF_Exp_3$Ideology_Score <- as.numeric(MF_Exp_3$Ideology_Score)
MF_Exp_3$Headline = ifelse(MF_Exp_3$Headline == 1,0,1)


#Run linear regression and produce coefficient values:
fit_Headline_MF_T_1 = glm(Match_FC ~ Headline + Education_Score + Age + Gender + Income_Score + Ideology_Score, data = MF_Exp_3)
#Produce clustere standard errors:
CI_Headline_MF_T_1 <- coefci(fit_Headline_MF_T_1, vcov. = vcovCL(fit_Headline_MF_T_1, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

lin_results_Headline_MF_T_1 = coeftest(fit_Headline_MF_T_1, vcov. = vcovCL(fit_Headline_MF_T_1, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

# Return Number of observations:
Obs_Tab_4_1 <- nrow(MF_Exp_3)
# Return R-squared
Rsq_Tab_4_1 <- rsq(fit_Headline_MF_T_1)
A_Rsq_Tab_4_1 <- rsq(fit_Headline_MF_T_1,adj=TRUE)
A_Rsq_Tab_4_1 <- round(A_Rsq_Tab_4_1,3)
Rsq_Tab_4_1 <- round(Rsq_Tab_4_1,3)

# Return F-statistic
glm.0 <- glm(Match_FC ~ 1,data=MF_Exp_3)
Results <- anova(fit_Headline_MF_T_1, glm.0, test="F")
F_Tab_4_1 <- Results$F[2]
F_Tab_4_1 <- round(F_Tab_4_1,3)
F_Tab_4_1 <- paste0(F_Tab_4_1,'^{***}')

#List of unique articles:
Search_Articles_15 <- unique(MF_Exp_3$Article_day)





############### Linear regression Results testing Hypothesis 1.2

#Create dataset needed:
Exp_3_Data <- rbind(Experiment_3_Data,Experiment_3_Data_T)
Exp_3_Data$Headline <- as.numeric(Exp_3_Data$Headline)
Exp_3_Data$Source <- as.numeric(Exp_3_Data$Source)
Exp_3_Data$Article <- as.numeric(Exp_3_Data$Article)
Exp_3_Data$Ideology_Score <- as.numeric(Exp_3_Data$Ideology_Score)
Full_Data <- Exp_3_Data %>% filter(Source == 1)

#Select variables:
MF_Exp_3 <- Full_Data %>% select(Match_FC,Headline,Education_Score,Age,Gender,Income_Score,Dummy_Congruence,Familiar_Dummy,Article_day,ResponseId,Ideology_Score)

#Remove NA values:
MF_Exp_3 <- na.omit(MF_Exp_3)

#Clean data:
MF_Exp_3$Match_FC <- as.numeric(MF_Exp_3$Match_FC)
MF_Exp_3$Age <- as.numeric(MF_Exp_3$Age)
MF_Exp_3$Education_Score <- as.numeric(MF_Exp_3$Education_Score)
MF_Exp_3$Income_Score <- as.numeric(MF_Exp_3$Income_Score)
MF_Exp_3$Ideology_Score <- as.numeric(MF_Exp_3$Ideology_Score)
MF_Exp_3$Headline = ifelse(MF_Exp_3$Headline == 1,0,1)

#Run linear regression and produce coefficient values:
fit_Headline_MF_T_2 = glm(Match_FC ~ Headline + Education_Score + Age + Gender + Income_Score + Ideology_Score, data = MF_Exp_3)
#Produce clustere standard errors:
CI_Headline_MF_T_2 <- coefci(fit_Headline_MF_T_2, vcov. = vcovCL(fit_Headline_MF_T_2, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

lin_results_Headline_MF_T_2 = coeftest(fit_Headline_MF_T_2, vcov. = vcovCL(fit_Headline_MF_T_2, cluster = list(MF_Exp_3$ResponseId), type = "HC0"))

# Return Number of observations:
Obs_Tab_4_2 <- nrow(MF_Exp_3)
# Return R-squared
Rsq_Tab_4_2 <- rsq(fit_Headline_MF_T_2)
A_Rsq_Tab_4_2 <- rsq(fit_Headline_MF_T_2,adj=TRUE)
A_Rsq_Tab_4_2 <- round(A_Rsq_Tab_4_2,3)
Rsq_Tab_4_2 <- round(Rsq_Tab_4_2,3)

# Return F-statistic
glm.0 <- glm(Match_FC ~ 1,data=MF_Exp_3)
Results <- anova(fit_Headline_MF_T_2, glm.0, test="F")
F_Tab_4_2 <- Results$F[2]
F_Tab_4_2 <- round(F_Tab_4_2,3)
F_Tab_4_2 <- paste0(F_Tab_4_2,'^{***}')

#List of unique articles:
Search_Articles_16 <- unique(MF_Exp_3$Article_day)




##############################################################################################################################

######################################################     Figure 3     ######################################################

##############################################################################################################################

# Y-axis labels:
Coef_names <- rev(c('[H1.1 Full Text]\n{All News}\n(No Source)',
                    '[H1.2 Full Text]\n{All News}\n(Source)'))

#Coefficients:
Coefficients <- c(fit_Headline_MF_T_1$coefficients[2],
                  fit_Headline_MF_T_2$coefficients[2])

#Upper Confidence Interval:
CI_Upper <- c(CI_Headline_MF_T_1[2,2],
              CI_Headline_MF_T_2[2,2])            

#Lower Confidence Interval:
CI_Lower <- c(CI_Headline_MF_T_1[2,1],
              CI_Headline_MF_T_2[2,1])           

#Create dataframe for figure:
d_matrix <- cbind(Coef_names,Coefficients,CI_Upper,CI_Lower)
rownames(d_matrix) <- c()
d_matrix <- data.frame(d_matrix)
d_matrix$Coefficients <- as.character(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.character(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.character(d_matrix$CI_Upper)
d_matrix$Coefficients <- as.numeric(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.numeric(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.numeric(d_matrix$CI_Upper)
d_matrix$x<-c(0.1,0.2)

#Plot Figure:
ggplot(data = d_matrix, aes(x = x, y = Coefficients)) +
  geom_hline(aes(yintercept = 0), color = "gray",
             linetype = 2, size = 1.2) +
  geom_point(size=4) +
  geom_linerange(aes(min = CI_Lower,
                     max = CI_Upper),
                 size=1.5) +
  scale_color_manual(values=c('red','blue','purple'), name = "Period") +
  ylab("\nEffect of type of information [in brackets] on matching                            \nfact-checker's evaluation of a type of article {in braces}                          \n when other types of information are provided (in parentheses)                       ") +
  theme_classic() +
  theme(axis.title.x = element_text(size=18),
        axis.text.x  = element_text(size=16),
        axis.title.y = element_text(size=16),
        axis.text.y  = element_text(size=22),
        plot.title = element_text(size = 16),
        legend.title = element_text(size=16),
        legend.text = element_text(size=14)) +
  scale_x_continuous(" \n",breaks=c(0.1,0.2),labels=Coef_names,limits=c(0.0,0.3)) +
  scale_y_continuous(breaks=c(-0.15,-0.1,-0.05,0,0.05,0.1,0.15),limits=c(-0.15,0.15)) +
  coord_flip()

#Save Figure:
ggsave('.//figures//Coefficients_1.png',height=8,width=8)


##############################################################################################################################

######################################################     Figure 4     ######################################################

##############################################################################################################################


# Y-axis labels:
Coef_names <- c('[H2.4 Source]\n{Mainstream News}\n(Headline/Lede)',
                '[H2.3 Source]\n{Low-Quality News}\n(Headline/Lede)',
                '[H2.2 Source]\n{Mainstream News}\n(Full Text)',
                '[H2.1 Source]\n{Low-Quality News}\n(Full Text)')

#Coefficients:
Coefficients <- c(fit_Standardize_MF_T_6$coefficients[2],
                  fit_Standardize_MF_T_5$coefficients[2],
                  fit_Standardize_MF_T_2$coefficients[2],
                  fit_Standardize_MF_T_1$coefficients[2])

#Upper Confidence Interval:
CI_Upper <- c(CI_Standardize_MF_T_6[2,2],
              CI_Standardize_MF_T_5[2,2],
              CI_Standardize_MF_T_2[2,2],
              CI_Standardize_MF_T_1[2,2])            

#Lower Confidence Interval:
CI_Lower <- c(CI_Standardize_MF_T_6[2,1],
              CI_Standardize_MF_T_5[2,1],
              CI_Standardize_MF_T_2[2,1],
              CI_Standardize_MF_T_1[2,1])


#Create dataframe for figure:
d_matrix <- cbind(Coef_names,Coefficients,CI_Upper,CI_Lower)
rownames(d_matrix) <- c()
d_matrix <- data.frame(d_matrix)
d_matrix$Coefficients <- as.character(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.character(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.character(d_matrix$CI_Upper)
d_matrix$Coefficients <- as.numeric(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.numeric(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.numeric(d_matrix$CI_Upper)
d_matrix$x<-c(0.1,0.2,0.3,0.4)

#Plot Figure:
ggplot(data = d_matrix, aes(x = x, y = Coefficients)) +
  geom_hline(aes(yintercept = 0), color = "gray",
             linetype = 2, size = 1.2) +
  geom_point(size=3) +
  geom_linerange(aes(min = CI_Lower,
                     max = CI_Upper),
                 size=1.5) +
  scale_color_manual(values=c('red','blue','purple'), name = "Period") +
  ylab("\nEffect of providing type of information [in brackets]                                  \n on rating a type of news article {in braces} as true                                     \n when other types of information are provided (in parentheses)                                        ") +
  theme_classic() +
  theme(axis.title.x = element_text(size=18),
        axis.text.x  = element_text(size=16),
        axis.title.y = element_text(size=16),
        axis.text.y  = element_text(size=22),
        plot.title = element_text(size = 16),
        legend.title = element_text(size=16),
        legend.text = element_text(size=14)) +
  scale_x_continuous(" \n",breaks=c(0.1,0.2,0.3,0.4),labels=Coef_names,limits=c(0.0,0.5)) +
  scale_y_continuous(breaks=c(-0.15,-0.1,-0.05,0,0.05,0.1,0.15),limits=c(-0.15,0.15)) +
  coord_flip()

#Save Figure:
ggsave('.//figures//Coefficients_2.png',height=8,width=8)


##############################################################################################################################

######################################################     Figure 5a     #####################################################

##############################################################################################################################

# Y-axis labels:
Coef_names <- rev(c('[H3.1 Additional Information]\n{True News}\n(Source and Full Text)',
                    '[H3.2 Additional Information]\n{False/Misleading News}\n(Source and Full Text)'))

#Coefficients:
Coefficients <- c(fit_Search_MF_T_1$coefficients[2],
                  fit_Search_MF_T_3$coefficients[2])

#Upper Confidence Interval:
CI_Upper <- c(CI_Search_MF_T_1[2,2],
              CI_Search_MF_T_3[2,2])            

#Lower Confidence Interval:
CI_Lower <- c(CI_Search_MF_T_1[2,1],
              CI_Search_MF_T_3[2,1])           

#Create dataframe for figure:
d_matrix <- cbind(Coef_names,Coefficients,CI_Upper,CI_Lower)
rownames(d_matrix) <- c()
d_matrix <- data.frame(d_matrix)
d_matrix$Coefficients <- as.character(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.character(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.character(d_matrix$CI_Upper)
d_matrix$Coefficients <- as.numeric(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.numeric(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.numeric(d_matrix$CI_Upper)
d_matrix$x<-c(0.1,0.2)

#Plot Figure:
ggplot(data = d_matrix, aes(x = x, y = Coefficients)) +
  geom_hline(aes(yintercept = 0), color = "gray",
             linetype = 2, size = 1.2) +
  geom_point(size=4) +
  geom_linerange(aes(min = CI_Lower,
                     max = CI_Upper),
                 size=1.5) +
  scale_color_manual(values=c('red','blue','purple'), name = "Period") +
  ylab("\nEffect of type of information [in brackets] on matching                \nfact-checker's evaluation of a type of article {in braces}              \n when other types of information are provided (in parentheses)                ") +
  theme_classic() +
  theme(axis.title.x = element_text(size=18),
        axis.text.x  = element_text(size=16),
        axis.title.y = element_text(size=16),
        axis.text.y  = element_text(size=22),
        plot.title = element_text(size = 16),
        legend.title = element_text(size=16),
        legend.text = element_text(size=14)) +
  scale_x_continuous(" \n",breaks=c(0.1,0.2),labels=Coef_names,limits=c(0.0,0.3)) +
  scale_y_continuous(breaks=c(-0.15,-0.1,-0.05,0,0.05,0.1,0.15,0.2,0.25),limits=c(-0.15,0.15)) +
  coord_flip()

#Save Figure:
ggsave('.//figures//Coefficients_3.png',height=8,width=11)

##############################################################################################################################

######################################################     Figure 5b     #####################################################

##############################################################################################################################

# Y-axis labels:
Coef_names <- c('[H3.3 Additional Information]\n{False/Misleading News}\n(Source and Full Text)')

#Coefficients:
Coefficients <- c(fit_Search_MF_T_2$coefficients[2])

#Upper Confidence Interval:
CI_Upper <- c(CI_Search_MF_T_2[2,2])            

#Lower Confidence Interval:
CI_Lower <- c(CI_Search_MF_T_2[2,1])


#Create dataframe for figure:
d_matrix <- cbind(Coef_names,Coefficients,CI_Upper,CI_Lower)
rownames(d_matrix) <- c()
d_matrix <- data.frame(d_matrix)
d_matrix$Coefficients <- as.character(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.character(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.character(d_matrix$CI_Upper)
d_matrix$Coefficients <- as.numeric(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.numeric(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.numeric(d_matrix$CI_Upper)
d_matrix$x<-c(0.1)


#Plot Figure:
ggplot(data = d_matrix, aes(x = x, y = Coefficients)) +
  geom_hline(aes(yintercept = 0), color = "gray",
             linetype = 2, size = 1.2) +
  geom_point(size=3) +
  geom_linerange(aes(min = CI_Lower,
                     max = CI_Upper),
                 size=1.5) +
  scale_color_manual(values=c('red','blue','purple'), name = "Period") +
  ylab("\nEffect of providing type of information [in brackets]            \n on rating a type of news article {in braces} as true                  \n when other types of information are provided (in parentheses)                 ") +
  theme_classic() +
  theme(axis.title.x = element_text(size=18),
        axis.text.x  = element_text(size=16),
        axis.title.y = element_text(size=16),
        axis.text.y  = element_text(size=22),
        plot.title = element_text(size = 16),
        legend.title = element_text(size=16),
        legend.text = element_text(size=14)) +
  scale_x_continuous(" \n",breaks=c(0.1),labels=Coef_names,limits=c(0.0,0.2)) +
  scale_y_continuous(breaks=c(-0.15,-0.1,-0.05,0,0.05,0.1,0.15),limits=c(-0.15,0.15)) +
  coord_flip()

#Save Figure:
ggsave('.//figures//Coefficients_4.png',height=8,width=11)



##############################################################################################################################

######################################################     Figure 6     ######################################################

##############################################################################################################################

#Read in Study 2 data (False/Misleading Articles)

Misl_False_Search_MF <- read_csv('.//data//MF_Search_Exp_Misl_False.csv',
                                 col_types = cols(
                                   .default = col_character()
                                 ))

#Create outcome variable:
Misl_False_Search_MF$Susc_FN <- ifelse(Misl_False_Search_MF$Evaluation == 'T',1,0)
Misl_False_Search_MF$Susc_FN <- ifelse(Misl_False_Search_MF$Evaluation == 'True',1,Misl_False_Search_MF$Susc_FN)

#Select variables needed:
Misl_False_Search_1 <- Misl_False_Search_MF %>% select(Susc_FN,Treat_Search,Education_Score,Age,Gender,Income_Score,Familiar_Dummy,Article_day,ResponseId,Ideology_Score,lean)

#Remove NA values:
Misl_False_Search_1 = na.omit(Misl_False_Search_1)

#Clean Data:
Misl_False_Search_1$Susc_FN <- as.numeric(Misl_False_Search_1$Susc_FN)
Misl_False_Search_1$Age <- as.numeric(Misl_False_Search_1$Age)
Misl_False_Search_1$Treat_Search <- as.numeric(Misl_False_Search_1$Treat_Search)
Misl_False_Search_1$Education_Score <- as.numeric(Misl_False_Search_1$Education_Score)
Misl_False_Search_1$Income_Score <- as.numeric(Misl_False_Search_1$Income_Score)
Misl_False_Search_1$Ideology_Score <- as.numeric(Misl_False_Search_1$Ideology_Score)

#Create Ideology Data:
Misl_False_Search_1$Ideology_group <- ifelse(Misl_False_Search_1$Ideology_Score > 0,'C','N')
Misl_False_Search_1$Ideology_group <- ifelse(Misl_False_Search_1$Ideology_Score < 0,'L',Misl_False_Search_1$Ideology_group)

#Subset data:
Misl_False_Search_C_C <- Misl_False_Search_1 %>% filter(Ideology_group == 'C' & lean == 'C')
Misl_False_Search_L_L <- Misl_False_Search_1 %>% filter(Ideology_group == 'L' & lean == 'L')
Misl_False_Search_C_L <- Misl_False_Search_1 %>% filter(Ideology_group == 'C' & lean == 'L')
Misl_False_Search_L_C <- Misl_False_Search_1 %>% filter(Ideology_group == 'L' & lean == 'C')

Misl_False_Search_Cong <- rbind(Misl_False_Search_C_C,Misl_False_Search_L_L)
Misl_False_Search_Incong <- rbind(Misl_False_Search_C_L,Misl_False_Search_L_C)


#Run linear regression and produce coefficient values:
fit_Search_MF_T_1 = glm(Susc_FN ~ Treat_Search + Education_Score + Age + Gender + Income_Score, data = Misl_False_Search_Cong)
#Produce clustere standard errors:
CI_Search_MF_T_1 = coefci(fit_Search_MF_T_1, vcov. = vcovCL(fit_Search_MF_T_1, cluster = list(Misl_False_Search_Cong$ResponseId), type = "HC0"))

lin_Search_Separate_MF_T_1 = coeftest(fit_Search_MF_T_1, vcov. = vcovCL(fit_Search_MF_T_1, cluster = list(Misl_False_Search_Cong$ResponseId), type = "HC0"))


# Return Number of observations:
Obs_Tab_5_1 <- nrow(Misl_False_Search_Cong)
# Return R-squared
Rsq_Tab_5_1 <- rsq(fit_Search_MF_T_1)
A_Rsq_Tab_5_1 <- rsq(fit_Search_MF_T_1,adj=TRUE)
A_Rsq_Tab_5_1 <- round(A_Rsq_Tab_5_1,3)
Rsq_Tab_5_1 <- round(Rsq_Tab_5_1,3)

# Return F-statistic
glm.0 <- glm(Susc_FN ~ 1,data=Misl_False_Search_Cong)
Results <- anova(fit_Search_MF_T_1, glm.0, test="F")
F_Tab_5_1 <- Results$F[2]
F_Tab_5_1 <- round(F_Tab_5_1,3)
F_Tab_5_1 <- paste0(F_Tab_5_1,'^{***}')

#List of unique articles
Search_Articles_1 <- unique(Misl_False_Search_Cong$Article_day)


#Run linear regression and produce coefficient values:
fit_Search_MF_T_3 = glm(Susc_FN ~ Treat_Search + Education_Score + Age + Gender + Income_Score, data = Misl_False_Search_Incong)
#Produce clustere standard errors:
CI_Search_MF_T_3 = coefci(fit_Search_MF_T_3, vcov. = vcovCL(fit_Search_MF_T_3, cluster = list(Misl_False_Search_Incong$ResponseId), type = "HC0"))

lin_Search_Separate_MF_T_3 = coeftest(fit_Search_MF_T_3, vcov. = vcovCL(fit_Search_MF_T_3, cluster = list(Misl_False_Search_Incong$ResponseId), type = "HC0"))


# Return Number of observations:
Obs_Tab_5_2 <- nrow(Misl_False_Search_Incong)
# Return R-squared
Rsq_Tab_5_2 <- rsq(fit_Search_MF_T_3)
A_Rsq_Tab_5_2 <- rsq(fit_Search_MF_T_3,adj=TRUE)
A_Rsq_Tab_5_2 <- round(A_Rsq_Tab_5_2,3)
Rsq_Tab_5_2 <- round(Rsq_Tab_5_2,3)


# Return F-statistic
glm.0 <- glm(Susc_FN ~ 1,data=Misl_False_Search_Incong)
Results <- anova(fit_Search_MF_T_3, glm.0, test="F")
F_Tab_5_2 <- Results$F[2]
F_Tab_5_2 <- round(F_Tab_5_2,3)
F_Tab_5_2 <- paste0(F_Tab_5_2,'^{***}')

#List of unique articles:
Search_Articles_1 <- unique(Misl_False_Search_Incong$Article_day)

# Y-axis labels:
Coef_names <- rev(c('Ideologically\nCongruent',
                    'Ideologically\nIncongruent'))

#Coefficients:
Coefficients <- c(fit_Search_MF_T_1$coefficients[2],
                  fit_Search_MF_T_3$coefficients[2])

#Upper Confidence Interval:
CI_Upper <- c(CI_Search_MF_T_1[2,2],
              CI_Search_MF_T_3[2,2])            

#Lower Confidence Interval:
CI_Lower <- c(CI_Search_MF_T_1[2,1],
              CI_Search_MF_T_3[2,1])           


#Create dataframe for figure:
d_matrix <- cbind(Coef_names,Coefficients,CI_Upper,CI_Lower)
rownames(d_matrix) <- c()
d_matrix <- data.frame(d_matrix)
d_matrix$Coefficients <- as.character(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.character(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.character(d_matrix$CI_Upper)
d_matrix$Coefficients <- as.numeric(d_matrix$Coefficients)
d_matrix$CI_Lower <- as.numeric(d_matrix$CI_Lower)
d_matrix$CI_Upper <- as.numeric(d_matrix$CI_Upper)
d_matrix$x<-c(0.1,0.2)

#Plot Figure:
ggplot(data = d_matrix, aes(x = x, y = Coefficients)) +
  geom_hline(aes(yintercept = 0), color = "gray",
             linetype = 2, size = 1.2) +
  geom_point(size=4) +
  geom_linerange(aes(min = CI_Lower,
                     max = CI_Upper),
                 size=1.5) +
  scale_color_manual(values=c('red','blue','purple'), name = "Period") +
  ylab("\nEffect of being encouraged to search for    \n additional information grouped by    \n ideological congruence with original article   ") +
  theme_classic() +
  theme(axis.title.x = element_text(size=18),
        axis.text.x  = element_text(size=16),
        axis.title.y = element_text(size=16),
        axis.text.y  = element_text(size=22),
        plot.title = element_text(size = 16),
        legend.title = element_text(size=16),
        legend.text = element_text(size=14)) +
  scale_x_continuous(" \n",breaks=c(0.1,0.2),labels=Coef_names,limits=c(0.0,0.3)) +
  scale_y_continuous(breaks=c(-0.15,-0.1,-0.05,0,0.05,0.1,0.15,0.2,0.25),limits=c(-0.15,0.25)) +
  coord_flip()

#Save Figure:
ggsave('.//figures//Coefficients_5.png',height=8,width=10)


writeLines(capture.output(sessionInfo()), "sessionInfo_Main_Text.txt")
